
--处理callcenter模块拒接事件
--取出发其事件的坐席
local ccagent=event:getHeader("CC-Agent");

--取出事件中的callcenter里面的callid
local  callnum=event:getHeader("CC-Member-CID-Number");


--取出发起事件的名称
local action=event:getHeader("CC-Action");

--取出挂断的原因
local hunpcase=event:getHeader("CC-Hangup-Cause");


local sessionuuid=event:getHeader("CC-Member-Session-UUID");



if(action == "member-queue-start" ) then

	freeswitch.consoleLog("info","--member"..callnum.."进入队列");
	local api=freeswitch.API();
        local reply=api:executeString("lua  notify.lua");

end


--判断如果桥接失败并且原因是NO_USER_RESPONSE 就有可能是拒绝
if(action == "bridge-agent-fail" and hunpcase =="NO_USER_RESPONSE") then

	freeswitch.consoleLog("info","开始处理拒绝事件");
	
	local api=freeswitch.API();
	local cmd="uuid_kill "..sessionuuid;
	freeswitch.consoleLog("info","执行脚本"..cmd);
	local reply=api:executeString(cmd);
	freeswitch.consoleLog("info","执行结果"..reply);


	local event = freeswitch.Event("CUSTOM", "NECO:REJECT");
	event:addHeader("Caller-Orig-Caller-ID-Number",callnum);
	event:addHeader("Caller-Callee-ID-Number",ccagent);
	event:addHeader("Unique-ID",sessionuuid);
	event:fire();
	freeswitch.consoleLog("info","处理拒绝事件完毕");

end;



